using Microsoft.AspNetCore.Mvc;
using ShopForWeb.Dto.ViewModels;
using ShopForWeb.UI.Extensions;
using ShopForWeb.UI.Filters;

namespace ShopForWeb.UI.Controllers.Admin;

[ManagerInfoFilter]
[Area("admin")]
[Route("[area]/error")]

public class ErrorController : Controller
{
  public IActionResult Index()
  {
    var exception = this.HttpContext.Session.Get<ExceptionViewModel>("exception");
    this.HttpContext.Session.Remove("exception");
    ViewBag.Data = exception;
    return View();
  }

  [ManagerInfoFilter]
  [Route("{code}")]
  public IActionResult Status(int code)
  {
    string message = "";
    switch (code)
    {
      case 404:
        {
          message = "请求不存在资源";
          break;
        }
    }
    ViewBag.Data = new
    {
      Code = code,
      Message = message
    };
    return View();
  }
}
